<template>
    <div class='basic-layout'>
       <div class="nav-side">
            <div class="logo">
                <img src="../assets/logo.png" alt="" />
                <span>Manager</span>
            </div>
            <el-menu
                default-active="2"
                router
                class="el-menu-vertical-demo"
                background-color="#001529"
                text-color="#fff"
                active-text-color="#ffd04b"
            >
            <tree-menu :menuList="menuList"></tree-menu>
      </el-menu>

       </div>

       <div class="content-right">
             <div class="nav-top">
                <div class="nav-left">
                    <div class="menu-fold">
                        <i class="el-icon-s-fold"></i>
                    </div>
                    <div class="bread">
                        <BreadCrumb></BreadCrumb>
                    </div>
                </div>
                <!-- 下拉 -->
                <div class="user-info">
                    <el-badge class="notice">
                        <i class="el-icon-bell"></i>
                    </el-badge>
                    <el-dropdown>
                      <span class="el-dropdown-link">
                          {{$store.state.userInfo.userName || ""}}
                      </span>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>邮箱 :{{$store.state.userInfo.userEmail}}</el-dropdown-item>
                        <el-dropdown-item>退出</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>    
                </div>
            </div>
            <div class="wrapper">
                <div class="main-page">
                     <router-view></router-view>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import BreadCrumb from "./BreadCrumb.vue";
import TreeMenu from "./TreeMenu.vue"
export default {
  data() {
    return {
      menuList : {}
    };
  },
  created(){
    this.getMenuList()
  },
  mounted() {},
  methods: {
    async getMenuList(){
      let res = await this.userApi.getPermissionList()
      console.log(res);
      this.$store.commit("saveMenuList",res.menuList)
      this.$store.commit("saveActionList",res.actionList)
      this.menuList = res.menuList
    }
  },
  components: {
    BreadCrumb,
    TreeMenu
  }
};
</script>

<style lang='scss' scoped>
.basic-layout {
  position: relative;

  .nav-side {
    position: fixed;
    width: 200px;
    height: 100vh;
    background-color: #001529;
    color: #fff;
    overflow-y: auto;

    .logo {
      display: flex;
      align-items: center;
      font-size: 18px;
      height: 50px;
      img {
        margin: 0 16px;
        width: 32px;
        height: 32px;
      }
    }

    .el-menu {
      border-right: 0;
    }
  }

  .content-right {
    margin-left: 200px;

    .nav-top {
      height: 50px;
      background-color: #fff;
      padding: 0 20px;
      border-bottom: 1px solid #ddd;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: fixed;
      right: 0;
      left: 200px;

      .nav-left {
        display: flex;
        align-items: center;
        .menu-fold {
          font-size: 18px;
          margin-right: 15px;
        }
      }
      .user-info {
        .notice {
          margin-right: 15px;
          line-height: 30px;
          cursor: pointer;
        }
        .user-link {
          cursor: pointer;
          color: #409eff;
        }
        .el-dropdown-menu__item:hover {
          color: #333 !important;
        }
      }
    }

    .wrapper {
      background: #eef0f3;
      height: 100%;
      // height : calc(100vh - 50px);
      padding: 20px;
      padding-top: 71px;
      .main-page {
        min-height: calc(100vh - 50px);
        height: 100%;
        background: #fff;
      }
    }
  }
}
</style>
